<!DOCTYPE html>
<html lang="zh-CN">
<base href="http://localhost:63342/Blog/" />
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>博客管理系统</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Microsoft YaHei', Arial, sans-serif;
            background-color: #f5f5f5;
            height: 100vh;
            overflow: hidden;
        }
        
        .admin-container {
            display: flex;
            height: 100vh;
        }
        
        .sidebar {
            width: 200px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            overflow-y: auto;
        }
        
        .main-content {
            flex: 1;
            display: flex;
            flex-direction: column;
        }
        
        .header {
            height: 60px;
            background: white;
            border-bottom: 1px solid #e0e0e0;
            display: flex;
            align-items: center;
            padding: 0 20px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        
        .content-area {
            flex: 1;
            padding: 20px;
            overflow-y: auto;
        }
        
        .logo {
            font-size: 18px;
            font-weight: bold;
            margin-bottom: 30px;
            padding: 20px;
            text-align: center;
            border-bottom: 1px solid rgba(255,255,255,0.2);
        }
        
        .nav-menu {
            list-style: none;
        }
        
        .nav-item {
            margin: 5px 0;
        }
        
        .nav-link {
            display: block;
            padding: 12px 20px;
            color: white;
            text-decoration: none;
            transition: all 0.3s ease;
            border-left: 3px solid transparent;
        }
        
        .nav-link:hover {
            background: rgba(255,255,255,0.1);
            border-left-color: #fff;
        }
        
        .nav-link.active {
            background: rgba(255,255,255,0.2);
            border-left-color: #fff;
        }
        
        .user-info {
            margin-left: auto;
            display: flex;
            align-items: center;
            gap: 10px;
        }
        
        .user-avatar {
            width: 35px;
            height: 35px;
            border-radius: 50%;
            background: #667eea;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-weight: bold;
        }
        
        .logout-btn {
            padding: 8px 16px;
            background: #ff4757;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 12px;
        }
        
        .logout-btn:hover {
            background: #ff3742;
        }
    </style>
</head>
<body>
    <div class="admin-container">
        <!-- 侧边栏 -->
        <div class="sidebar">
            <div class="logo">
                📝 博客管理
            </div>
            <ul class="nav-menu">
                <li class="nav-item">
                    <a href="admin.php?a=index" class="nav-link active" >
                        📊 仪表盘
                    </a>
                </li>
                <li class="nav-item">
                    <a href="admin.php?c=Article&a=article_manage" class="nav-link" >
                        📝 文章管理
                    </a>
                </li>
                <li class="nav-item">
                    <a href="admin.php?c=User&a=user_manage" class="nav-link" >
                        👥 用户管理
                    </a>
                </li>
                <li class="nav-item">
                    <a href="admin.php?c=Setting&a=setting" class="nav-link" >
                        ⚙️ 系统设置
                    </a>
                </li>
            </ul>
        </div>
        
        <!-- 主内容区 -->
        <div class="main-content">
            <!-- 顶部导航 -->
            <div class="header">
                <h2 id="page-title">仪表盘</h2>
                <div class="user-info">
                    <div class="user-avatar">A</div>
                    <span>管理员</span>
                    <button class="logout-btn" onclick="logout()">退出</button>
                </div>
            </div>
            
            <!-- 内容区域 -->
            <div class="content-area" id="content-area">
                <!-- 默认加载仪表盘内容 -->
                <div id="center-content">
                    <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px;">
                        <div style="background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);">
                            <h3 style="color: #667eea; margin-bottom: 10px;">📝 总文章数</h3>
                            <div style="font-size: 24px; font-weight: bold; color: #333;"><?php echo isset($arrs) ? count($arrs) : 0; ?></div>
                        </div>
                        <div style="background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);">
                            <h3 style="color: #667eea; margin-bottom: 10px;">👥 用户数</h3>
                            <div style="font-size: 24px; font-weight: bold; color: #333;">156</div>
                        </div>
                        <div style="background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);">
                            <h3 style="color: #667eea; margin-bottom: 10px;">📈 访问量</h3>
                            <div style="font-size: 24px; font-weight: bold; color: #333;">2,847</div>
                        </div>
                        <div style="background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);">
                            <h3 style="color: #667eea; margin-bottom: 10px;"> 评论数</h3>
                            <div style="font-size: 24px; font-weight: bold; color: #333;">89</div>
                        </div>
                    </div>
                    
                    <div style="margin-top: 30px; background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);">
                        <h3 style="margin-bottom: 15px; color: #333;">最新文章</h3>
                        <?php if (!empty($arrs)): ?>
                            <div style="max-height: 300px; overflow-y: auto;">
                                <?php foreach (array_slice($arrs, 0, 5) as $row): ?>
                                    <div style="padding: 10px; border-bottom: 1px solid #f0f0f0; display: flex; justify-content: space-between; align-items: center;">
                                        <div>
                                            <strong><?php echo htmlspecialchars($row['title'] ?? '无标题'); ?></strong>
                                            <div style="font-size: 12px; color: #666; margin-top: 2px;">
                                                <?php echo htmlspecialchars($row['created_at'] ?? date('Y-m-d H:i:s')); ?>
                                            </div>
                                        </div>
                                        <span style="background: #667eea; color: white; padding: 2px 8px; border-radius: 12px; font-size: 12px;">
                                            <?php echo htmlspecialchars($row['status'] ?? '已发布'); ?>
                                        </span>
                                    </div>
                                <?php endforeach; ?>
                            </div>
                        <?php else: ?>
                            <p style="color: #666; text-align: center; padding: 20px;">暂无文章数据</p>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>
        {literal}
        function loadContent(type) {
            // 更新导航状态
            document.querySelectorAll('.nav-link').forEach(link => {
                link.classList.remove('active');
            });
            event.target.classList.add('active');
            
            // 更新页面标题
            const titles = {
                'center': '仪表盘',
                'main': '文章管理',
                'left': '用户管理',
                'right': '系统设置'
            };
            document.getElementById('page-title').textContent = titles[type];
            
            // 这里可以通过 AJAX 加载不同模块的内容
            // 目前先显示简单的提示
            document.getElementById('content-area').innerHTML = `
                <div style="background: white; padding: 40px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); text-align: center;">
                    <h3 style="color: #667eea; margin-bottom: 10px;">${titles[type]}</h3>
                    <p style="color: #666;">该功能正在开发中...</p>
                </div>
            `;
        }
        
        function logout() {
            if (confirm('确定要退出登录吗？')) {
                alert('退出登录功能待实现');
                // 这里可以跳转到登录页面或执行退出逻辑
            }
        }

        {/literal}
    </script>
</body>
</html>